//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "ModelTotalResults.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* filenameIn  = NULL;
  String* filenameOut = NULL;
  String* name        = NULL;
  String* scheme      = NULL;
  String* selection   = NULL;
  
  if (argc < 6) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./LoadModelResult <Filename with Classifier Output - In>";
    cout <<                  " <Filename with Classifier Output - Out>";
    cout <<                  " <Classifier Model>";
    cout <<                  " <Scheme>";
    cout <<                  " <Feature Selection Algorithm used>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    filenameIn  = new String(argv[1]);
    filenameOut = new String(argv[2]);
    name        = new String(argv[3]);
    scheme      = new String(argv[4]);
    selection   = new String(argv[5]);
    
    cout << "-----------------------------------------------------------------------------------" << endl;
    cout << "  Filename with Classifier Output - In : " << argv[1] << endl;
    cout << " Filename with Classifier Output - Out : " << argv[2] << endl;    
    cout << "                      Classifier Model : " << argv[3] << endl;    
    cout << "                                Scheme : " << argv[4] << endl;    
    cout << "      Feature Selection Algorithm used : " << argv[5] << endl;    
    cout << "-----------------------------------------------------------------------------------" << endl;
    
  }
  
  ModelTotalResults* modelTotalResults = new ModelTotalResults ();
  
  cout << "Preparing the files..." << endl;
  modelTotalResults->FilenameIn(filenameIn);
  modelTotalResults->FilenameOut(filenameOut);
  modelTotalResults->Name(name);
  modelTotalResults->Scheme(scheme);
  modelTotalResults->Selection(selection);
  
  cout << "Loading the data..." << endl;
  if (!modelTotalResults->LoadFromFile())
    cout << "Error loading data!" << endl;
  
  cout << "Writing results to output file..." << endl;
  if (!modelTotalResults->WriteToFile())
    cout << "Error writing the model output!" << endl;
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  cout << "-----------------------------------------------------------------------------------" << endl;
  
  if (modelTotalResults) delete modelTotalResults;
  
  if (filenameIn)           delete filenameIn;
  if (filenameOut)          delete filenameOut;
  if (name)                 delete name;
  if (scheme)               delete scheme;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

